<?php

function __autoload($classname) {
	static $lib_path ;
	if(!$lib_path) { 
		$lib_path = dirname(__FILE__)."/../inc/curlm/";
	}
	include("$lib_path/$classname.php");
}

class MyCurlTask extends CurlTaskAbstract {
	protected function onFinished() {
		$info = curl_getinfo($this->_curl);
		$contents = curl_multi_getcontent($this->_curl);
		//do something
		//todo
	}
}


$tunnels = 4;
$tasklist = new CurlTaskList();

$urls = array(
		"http://www.baidu.com/duty/",
		"http://www.google.com.hk/intl/zh-CN/privacy/",
		"http://www.baidu.com/home.html",
		"http://www.google.com.hk/intl/zh-CN/corporate/privacy_principles.html",
		"http://www.baidu.com/duty/right.html",
		"http://www.google.com.hk/intl/zh-CN/privacy/ads/",
	);

$opts = array(
	CURLOPT_VERBOSE =>0 ,
	CURLOPT_RETURNTRANSFER => true,
	);


//make tasks
foreach($urls as $url) {
	$tasklist->push(new MyCurlTask($url, $opts));
}


$curlm = new CurlMFetcher($tasklist, $tunnels);
$curlm->setDebug(true);

//run
$curlm->run();


